#pragma once

#include "PDMapCreator.h"
#include "GlobalTypes.h"
#include "db\DbProxy.h"

#define WM_THREAD (WM_USER+1)     

#define TM_COUNT 1
#define TM_CONVERT 2
#define TM_FINISHED 3

enum PassType {
	COUNT = 1,
	CONVERT
};

class CConvertor
{
public:
	CConvertor(void);
	~CConvertor(void);

	// vykonna metoda pro stahovani, vola se jako samostatny thread
	DWORD ThreadFunc();
		
	void Lock();
	void Unlock();
	void Start();
	void Stop();  // interni zastaveni prace
	void Close(); // externi zastaveni

	BOOL Running() { return m_running; };

	SourceType	m_sourceType;
	CString		m_sourceFolder;
	CDbProxy*	m_mapFile;

protected:
	CRITICAL_SECTION	m_csData;	// Critical section 
	HANDLE				m_hThread;	// downloading thread

	BOOL				m_running;
	BOOL				m_stopThread;

	// prochazi slozky a zpracovava jejich obsah
	void ProcessFolder(CString aFolder, PassType aPass);

private:
	int	m_count;

	int hex2dec(CString hex);
};
